Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up logging #63

Merged
merged 3 commits into from
Jul 22, 2024
Merged

Set up logging #63

merged 3 commits into from
Jul 22, 2024

Conversation

aaprasad
Copy link
Contributor

@aaprasad aaprasad commented Jun 12, 2024

Here we address #57 by setting up the logging module in dreem

Summary by CodeRabbit

  • Documentation

    • Updated documentation links and command-line interface (CLI) instructions in README.md.
    • Added detailed CLI usage instructions in docs/cli.md.
    • Introduced a new code badge in docs/index.md.
    • Simplified CLI commands in docs/usage.md.
  • New Features

    • Introduced dreem-train and dreem-track commands for training and inference.
  • Refactor

    • Replaced print statements with logging across various files for improved logging practices.
    • Updated type annotations to use | syntax for union types.
  • Chores

    • Added new function setup_logging() for logging configuration.
    • Enhanced logging for error handling and debugging.

@aaprasad aaprasad changed the base branch from main to aadi/update-python-version June 12, 2024 19:02
Copy link
Contributor

coderabbitai bot commented Jun 12, 2024

Walkthrough

The updates to the dreem project enhance documentation and the command-line interface (CLI) for training and inference tasks. Key changes include revised URLs, streamlined script executions using new commands (dreem-train and dreem-track), and improvements in type annotations and logging throughout the codebase. These modifications enhance usability, readability, and overall maintainability of the project.

Changes

Files/Directories Change Summary
README.md, docs/usage.md Updated documentation links and simplified CLI commands for training and inference.
docs/cli.md Introduced a new file detailing CLI commands for training, inference, and visualization.
docs/index.md Added a new code badge linking to the GitHub stars count.
dreem/__init__.py Added setup_logging() function for enhanced logging configuration.
dreem/datasets/... Updated type annotations to use `
dreem/inference/... Enhanced logging, updated type annotations, and replaced print statements with logging calls.
dreem/io/... Improved logging mechanisms and added logger initialization for better error handling.
dreem/training/... Enhanced logging within training functions and removed unused imports.
logging.yaml Introduced structured logging configuration for the application.
tests/test_datasets.py Removed commented-out print statements for cleaner test code.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant DreemTrain
    participant DreemTrack

    User->>CLI: Execute `dreem-train` command
    CLI->>DreemTrain: Start training process
    DreemTrain-->>CLI: Training status

    User->>CLI: Execute `dreem-track` command
    CLI->>DreemTrack: Start inference process
    DreemTrack-->>CLI: Inference status
Loading

Poem

In the land of code, where dreams take flight,
dreem-train and dreem-track shine so bright.
With docs anew and logging clear,
Simpler commands, no need to fear.
Type hints refined, the code's delight,
Progress marches on, in the soft moonlight.
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 39

Outside diff range and nitpick comments (55)
dreem/__init__.py (1)

Line range hint 6-15: Remove unused imports to clean up the code.

- from dreem.models.global_tracking_transformer import GlobalTrackingTransformer
- from dreem.models.gtr_runner import GTRRunner
- from dreem.models.transformer import Transformer
- from dreem.models.visual_encoder import VisualEncoder
- from dreem.io.frame import Frame
- from dreem.io.instance import Instance
- from dreem.io.association_matrix import AssociationMatrix
- from dreem.io.config import Config
- from dreem.io.visualize.annotate_video
Tools
Ruff

3-3: logging.config imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


4-4: dreem.version.__version__ imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: dreem.models.global_tracking_transformer.GlobalTrackingTransformer imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

docs/index.md (5)

Line range hint 20-20: Ensure headings are surrounded by blank lines to comply with Markdown best practices.

+ <!-- Add a blank line above and below each heading -->

Also applies to: 21-21, 25-25, 26-26, 27-27, 31-31, 35-35, 39-39


Line range hint 21-21: Remove trailing punctuation from headings to comply with Markdown best practices.

- #### Clone the repository:
+ #### Clone the repository

Also applies to: 25-25, 26-26, 31-31


Line range hint 22-22: Ensure fenced code blocks are surrounded by blank lines.

+ <!-- Add a blank line above and below each code block -->

Also applies to: 24-24, 28-28, 30-30, 32-32, 34-34, 36-36, 38-38, 40-40


Line range hint 40-40: Specify the language for the fenced code block to enable syntax highlighting.

- ```
+ ```bash

Line range hint 42-42: Ensure the file ends with a single newline character.

+ <!-- Ensure there's a newline at the end of the file -->
dreem/training/train.py (2)

Line range hint 37-37: Optimize dictionary key check.

- if "batch_config" in cfg.keys():
+ if "batch_config" in cfg:

[!TIP]
Codebase Verification

The context around the try block shows that it handles a potential KeyError when accessing an environment variable. However, there are no additional try-except blocks or with statements for broader resource management and error handling in the training setup.

  • Ensure proper resource management and error handling in the training setup, especially around resource-intensive operations like model training and data loading.
Analysis chain

Line range hint 78-90: Ensure proper resource management and error handling in the training setup.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify proper error handling and resource management in training setup.

# Test: Search for error handling patterns. Expect: Proper try-except blocks around resource-intensive operations.
rg --type python $'try { $$$ } catch { $$$ }' ./dreem/training/train.py

Length of output: 186



Script:

#!/bin/bash
# Description: Verify proper error handling and resource management in training setup.

# Test: Search for try-except blocks. Expect: Proper try-except blocks around resource-intensive operations.
rg --type py 'try:' ./dreem/training/train.py

# Test: Search for with statements. Expect: Proper use of context managers for resource management.
rg --type py 'with ' ./dreem/training/train.py

Length of output: 277



Script:

#!/bin/bash
# Description: Extract context around the try block and check for resource management practices.

# Extract 10 lines before and after the try block to understand the context.
rg --type py -A 10 -B 10 'try:' ./dreem/training/train.py

Length of output: 728

dreem/inference/track.py (2)

Line range hint 37-37: Optimize loop variable usage.

- for i, instance in enumerate(frame.instances):
+ for _i, instance in enumerate(frame.instances):
Tools
Ruff

20-20: Undefined name dreem (F821)


Line range hint 101-101: Optimize dictionary key check.

- if "checkpoints" in cfg.keys():
+ if "checkpoints" in cfg:
Tools
Ruff

20-20: Undefined name dreem (F821)

dreem/models/global_tracking_transformer.py (2)

Line range hint 81-82: Undefined names in type hints.

- ref_instances: list["Instance"], query_instances: list["Instance"] = None
+ ref_instances: list[Instance], query_instances: list[Instance] = None

- instances: list["Instance"], force_recompute: bool = False
+ instances: list[Instance], force_recompute: bool = False

Also applies to: 103-103


Line range hint 82-82: Undefined name 'AssociationMatrix' in return type.

- ) -> list["AssociationMatrix"]:
+ ) -> list[AssociationMatrix]:
dreem/datasets/base_dataset.py (1)

124-124: Clarify the purpose of no_batching_fn in the docstring.

Consider enhancing the docstring of no_batching_fn to explain why this method is necessary and how it differs from standard batching functions.

dreem/datasets/microscopy_dataset.py (2)

Line range hint 85-85: Replace lambda with a function definition for better readability and maintainability.

- parser = lambda x: data_utils.parse_synthetic(x, source=source)
+ def parser(x):
+     return data_utils.parse_synthetic(x, source=source)

Using a function definition instead of a lambda expression enhances readability and maintainability, especially for more complex logic.


Line range hint 171-172: Combine nested if statements into a single statement.

- if len(img.shape) == 2:
-     img = img.unsqueeze(0)
- elif len(img.shape) == 3:
-     if img.shape[2] == 3:
-         img = img.T
+ if len(img.shape) == 2:
+     img = img.unsqueeze(0)
+ elif len(img.shape) == 3 and img.shape[2] == 3:
+     img = img.T

Combining these conditions into a single statement simplifies the code and reduces nesting.

dreem/models/model_utils.py (1)

Line range hint 19-19: Loop control variable i is not used within the loop body.

- for i, instance in enumerate(instances):
+ for _i, instance in enumerate(instances):
Tools
Ruff

8-8: Undefined name dreem (F821)

dreem/inference/boxes.py (1)

Line range hint 129-129: Use f-string for better readability and performance.

- "Indexing on Boxes with {} failed to return a matrix!".format(item)
+ f"Indexing on Boxes with {item} failed to return a matrix!"
dreem/datasets/cell_tracking_dataset.py (1)

Line range hint 132-135: Simplify the assignment using a ternary operator.

-        if self.gt_list is not None:
-            gt_list = self.gt_list[label_idx]
-        else:
-            gt_list = None
+        gt_list = self.gt_list[label_idx] if self.gt_list is not None else None
dreem/models/gtr_runner.py (1)

5-5: Add a module-level docstring for the logging import to explain its usage.

dreem/inference/metrics.py (2)

Line range hint 142-142: Rename the unused loop variable fidx to _fidx to indicate it is intentionally unused.

- for fidx, frame in enumerate(frames):
+ for _fidx, frame in enumerate(frames):

Line range hint 230-230: Rename the unused loop variable metric_name to _metric_name to indicate it is intentionally unused.

- for metric_name, metric in metrics.items():
+ for _metric_name, metric in metrics.items():
dreem/inference/track_queue.py (2)

Line range hint 199-202: Replace the if-else block with a ternary operator for cleaner code.

- if isinstance(frame.video, str):
-     vid_name = frame.video
- else:
-     vid_name = frame.video.filename
+ vid_name = frame.video if isinstance(frame.video, str) else frame.video.filename

Line range hint 211-211: Use key not in dict instead of key not in dict.keys() for better performance.

- if pred_track_id not in self._queues.keys():
+ if pred_track_id not in self._queues:
dreem/io/visualize.py (1)

Line range hint 286-286: Rename the unused loop variable idx to _idx to indicate it is intentionally unused.

- for idx, (ds_name, data) in enumerate([(save_path, annotated_frames)]):
+ for _idx, (ds_name, data) in enumerate([(save_path, annotated_frames)]):
dreem/io/association_matrix.py (5)

Line range hint 41-44: Remove extraneous parentheses to improve readability.

- raise ValueError(
-     (
-         "Ref instances must equal number of columns in Association matrix"
-         f"Found {len(value)} ref instances but {self.matrix.shape[-1]} columns."
-     )
- )
+ raise ValueError(
+     "Ref instances must equal number of columns in Association matrix"
+     f"Found {len(value)} ref instances but {self.matrix.shape[-1]} columns."
+ )

Line range hint 60-63: Remove extraneous parentheses to improve readability.

- raise ValueError(
-     (
-         "Query instances must equal number of rows in Association matrix"
-         f"Found {len(value)} query instances but {self.matrix.shape[0]} rows."
-     )
- )
+ raise ValueError(
+     "Query instances must equal number of rows in Association matrix"
+     f"Found {len(value)} query instances but {self.matrix.shape[0]} rows."
+ )

Line range hint 117-117: Remove extraneous f prefix from the string as there are no placeholders.

- f"Mismatched # of rows and labels!",
+ "Mismatched # of rows and labels!",

Line range hint 143-143: Remove extraneous f prefix from the string as there are no placeholders.

- f"Mismatched # of columns and labels!",
+ "Mismatched # of columns and labels!",

Line range hint 208-209: Rename unused loop control variables to indicate they are not used.

- for row_track, row_instances in row_tracks.items():
-     for col_track, col_instances in col_tracks.items():
+ for _row_track, row_instances in row_tracks.items():
+     for _col_track, col_instances in col_tracks.items():
tests/test_datasets.py (1)

Line range hint 11-11: Remove unused import to clean up the code.

- from dreem.models.model_utils get_device
dreem/datasets/sleap_dataset.py (1)

Line range hint 150-150: Rename unused loop control variable to indicate it is not used.

- for i, frame_ind in enumerate(frame_idx):
+ for _i, frame_ind in enumerate(frame_idx):
dreem/models/embedding.py (1)

Line range hint 154-157: Remove extraneous parentheses to improve readability.

- raise RuntimeError(
-     (
-         f"Output embedding dimension is {emb.shape[-1]} but requested {self.features} dimensions! \n"
-         f"hint: Try turning the MLP on by passing `mlp_cfg` to the constructor to project to the correct embedding dimensions."
-     )
- )
+ raise RuntimeError(
+     f"Output embedding dimension is {emb.shape[-1]} but requested {self.features} dimensions! \n"
+     f"hint: Try turning the MLP on by passing `mlp_cfg` to the constructor to project to the correct embedding dimensions."
+ )
dreem/io/config.py (3)

Line range hint 86-86: Undefined name GlobalTrackingTransformer. Ensure that the necessary imports are included or correct the type annotations.

- def get_model(self) -> "GlobalTrackingTransformer":
+ from dreem.models import GlobalTrackingTransformer
+ def get_model(self) -> GlobalTrackingTransformer:

Line range hint 98-98: Undefined name GTRRunner. Ensure that the necessary imports are included or correct the type annotations.

- def get_gtr_runner(self) -> "GTRRunner":
+ from dreem.models import GTRRunner
+ def get_gtr_runner(self) -> GTRRunner:

Line range hint 405-409: Use a ternary operator for cleaner code when setting trainer_params.

- if "trainer" in self.cfg:
-     trainer_params = self.cfg.trainer
- else:
-     trainer_params = {}
+ trainer_params = self.cfg.trainer if "trainer" in self.cfg else {}
docs/usage.md (10)

Line range hint 3-3: Consider replacing "thru" with "through" for a more formal tone.

- thru training and running inference.
+ through training and running inference.
Tools
LanguageTool

[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...

Markdownlint

116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


Line range hint 36-36: Clarify "In order to train a model you need 2 things." to be more concise.

- In order to train a model you need 2 things.
+ To train a model, you need two things:
Tools
LanguageTool

[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...

Markdownlint

116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


Line range hint 41-41: Add a comma after "microscopy data" for better readability.

- For microscopy data we currently support `.tif` files.
+ For microscopy data, we currently support `.tif` files.
Tools
LanguageTool

[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...

Markdownlint

116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


Line range hint 47-47: Replace "a couple methods" with "a couple of methods" for grammatical correctness.

- we recommend a couple methods.
+ we recommend a couple of methods.
Tools
LanguageTool

[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...

Markdownlint

116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


Line range hint 49-49: Correct "work flow" to "workflow" for consistency.

- through their work flow.
+ through their workflow.
Tools
LanguageTool

[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...

Markdownlint

116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


Line range hint 52-52: Add periods to "e.g" and "etc," and insert a comma before "but."

- (e.g DeepLabCut or ilastik etc), the easiest
+ (e.g., DeepLabCut or ilastik, etc.), the easiest
Tools
LanguageTool

[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...

Markdownlint

116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


Line range hint 54-54: Add a hyphen to "high quality" when used as a compound adjective.

- to have high quality data.
+ to have high-quality data.
Tools
LanguageTool

[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...

Markdownlint

116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


Line range hint 58-58: Insert a comma before "however."

- unavoidable however, in cases of occlusion and overlap.
+ unavoidable, however, in cases of occlusion and overlap.
Tools
LanguageTool

[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...

Markdownlint

116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


Line range hint 63-63: Simplify "In order to use the SLEAP gui" to a more concise form.

- In order to use the SLEAP gui
+ To use the SLEAP gui
Tools
LanguageTool

[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...

Markdownlint

116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


Line range hint 70-70: Correct "its" to "it's" in two places for grammatical accuracy.

- easy its best to save your labels and vid files
+ easy it's best to save your labels and video files
- Its also just best practice
+ It's also just best practice
Tools
LanguageTool

[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...

Markdownlint

116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines

dreem/io/frame.py (2)

3-3: Consider adding a module-level docstring to explain the purpose of the __future__ import annotations for clarity.


Line range hint 556-556: Use key in dict instead of key in dict.keys() for checking key existence in dictionaries. This is more Pythonic and efficient.

- if key in dict.keys():
+ if key in dict:
README.md (5)

Line range hint 43-43: Replace informal language for professionalism.

- Here we describe a basic workflow from setting up data thru training and running inference.
+ Here we describe a basic workflow from setting up data through training and running inference.

Line range hint 43-43: Consider adding a comma for better readability.

- Regardless if you're only interested in running inference, we recommend at least skimming thru the entire tutorial as there may be useful information that applies to both training and inference!
+ Regardless, if you're only interested in running inference, we recommend at least skimming through the entire tutorial as there may be useful information that applies to both training and inference!

Line range hint 75-75: Clarify the necessity of the steps listed.

- In order to train a model you need 2 things.
+ To train a model, you need 2 things:

Line range hint 85-85: Use "a couple of" instead of "a couple" for formal writing.

- To generate your initial labels we recommend a couple methods.
+ To generate your initial labels, we recommend a couple of methods.

Line range hint 89-89: Correct the abbreviation and punctuation.

- If you'd like to use a different method, (e.g DeepLabCut or ilastik etc), the easiest way to make your data compatible with `dreem` is to convert your labels to a `.slp` file and your video to an [`imageio`-supported]((https://imageio.readthedocs.io/en/v2.4.1/formats.html)) video format.
+ If you'd like to use a different method (e.g., DeepLabCut or ilastik, etc.), the easiest way to make your data compatible with `dreem` is to convert your labels to a `.slp` file and your video to an [`imageio`-supported](https://imageio.readthedocs.io/en/v2.4.1/formats.html) video format.
dreem/inference/tracker.py (1)

Line range hint 179-179: The variable curr_track is used before it is defined, which will lead to a runtime error. Initialize curr_track before its use.

+ curr_track = 0
  for i, instance in enumerate(frames[batch_idx].instances):
      if instance.pred_track_id == -1:
          curr_track += 1
          instance.pred_track_id = curr_track_id
dreem/io/instance.py (2)

Line range hint 215-215: Avoid using mutable default arguments for function parameters to prevent unintended side effects.

-    def to_slp(self, track_lookup: dict[int, sio.Track] = {}):
+    def to_slp(self, track_lookup: dict[int, sio.Track] = None):
+        if track_lookup is None:
+            track_lookup = {}

Line range hint 293-293: Simplify the return statements by returning the condition directly.

-        if self._gt_track_id.shape[0] == 0:
-            return False
-        else:
-            return True
+        return self._gt_track_id.shape[0] != 0

Also applies to: 325-325, 365-365, 435-435, 473-473

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 25b6d96 and 4561d0f.

Files selected for processing (40)
  • README.md (6 hunks)
  • docs/cli.md (1 hunks)
  • docs/index.md (1 hunks)
  • docs/usage.md (5 hunks)
  • dreem/init.py (2 hunks)
  • dreem/datasets/base_dataset.py (5 hunks)
  • dreem/datasets/cell_tracking_dataset.py (3 hunks)
  • dreem/datasets/data_utils.py (6 hunks)
  • dreem/datasets/eval_dataset.py (2 hunks)
  • dreem/datasets/microscopy_dataset.py (3 hunks)
  • dreem/datasets/sleap_dataset.py (4 hunks)
  • dreem/datasets/tracking_dataset.py (2 hunks)
  • dreem/inference/boxes.py (6 hunks)
  • dreem/inference/metrics.py (4 hunks)
  • dreem/inference/post_processing.py (3 hunks)
  • dreem/inference/track.py (5 hunks)
  • dreem/inference/track_queue.py (7 hunks)
  • dreem/inference/tracker.py (11 hunks)
  • dreem/io/association_matrix.py (5 hunks)
  • dreem/io/config.py (8 hunks)
  • dreem/io/frame.py (10 hunks)
  • dreem/io/instance.py (9 hunks)
  • dreem/io/track.py (2 hunks)
  • dreem/io/visualize.py (8 hunks)
  • dreem/models/embedding.py (4 hunks)
  • dreem/models/global_tracking_transformer.py (2 hunks)
  • dreem/models/gtr_runner.py (4 hunks)
  • dreem/models/model_utils.py (4 hunks)
  • dreem/models/transformer.py (6 hunks)
  • dreem/models/visual_encoder.py (3 hunks)
  • dreem/training/init.py (1 hunks)
  • dreem/training/losses.py (4 hunks)
  • dreem/training/train.py (5 hunks)
  • environment.yml (1 hunks)
  • environment_cpu.yml (1 hunks)
  • environment_osx-arm64.yml (1 hunks)
  • logging.yaml (1 hunks)
  • mkdocs.yml (1 hunks)
  • pyproject.toml (2 hunks)
  • tests/test_datasets.py (1 hunks)
Files not reviewed due to errors (1)
  • dreem/datasets/data_utils.py (no review received)
Files skipped from review due to trivial changes (4)
  • dreem/datasets/tracking_dataset.py
  • dreem/training/init.py
  • environment.yml
  • mkdocs.yml
Additional context used
Ruff
dreem/__init__.py

3-3: logging.config imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


4-4: dreem.version.__version__ imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


6-6: dreem.models.global_tracking_transformer.GlobalTrackingTransformer imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


7-7: dreem.models.gtr_runner.GTRRunner imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


8-8: dreem.models.transformer.Transformer imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


9-9: dreem.models.visual_encoder.VisualEncoder imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


11-11: dreem.io.frame.Frame imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


12-12: dreem.io.instance.Instance imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


13-13: dreem.io.association_matrix.AssociationMatrix imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


14-14: dreem.io.config.Config imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


15-15: dreem.io.visualize.annotate_video imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


19-19: dreem.inference.tracker.Tracker imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


30-30: Unnecessary open mode parameters (UP015)

Remove open mode parameters


34-34: Local variable logger is assigned to but never used (F841)

Remove assignment to unused variable logger

dreem/io/track.py

17-17: Remove quotes from type annotation (UP037)

Remove quotes


17-17: Undefined name Instance (F821)


46-46: Remove quotes from type annotation (UP037)

Remove quotes


46-46: Undefined name Instances (F821)


64-64: Remove quotes from type annotation (UP037)

Remove quotes


64-64: Undefined name Frame (F821)


80-80: Remove quotes from type annotation (UP037)

Remove quotes


80-80: Undefined name Instance (F821)


80-80: Remove quotes from type annotation (UP037)

Remove quotes


80-80: Undefined name Instance (F821)

dreem/training/train.py

37-37: Use key in dict instead of key in dict.keys() (SIM118)

Remove .keys()

dreem/inference/track.py

20-20: Undefined name dreem (F821)


37-37: Loop control variable i not used within loop body (B007)

Rename unused i to _i


101-101: Use key in dict instead of key in dict.keys() (SIM118)

Remove .keys()


119-119: f-string without any placeholders (F541)

Remove extraneous f prefix

dreem/models/global_tracking_transformer.py

81-81: Undefined name Instance (F821)


81-81: Undefined name Instance (F821)


82-82: Undefined name AssociationMatrix (F821)


103-103: Undefined name Instance (F821)

dreem/datasets/microscopy_dataset.py

85-85: Do not assign a lambda expression, use a def (E731)

Rewrite parser as a def


171-172: Use a single if statement instead of nested if statements (SIM102)

Combine if statements using and

dreem/models/model_utils.py

8-8: Undefined name dreem (F821)


19-19: Loop control variable i not used within loop body (B007)

Rename unused i to _i


32-32: Undefined name dreem (F821)


33-33: Undefined name dreem (F821)

dreem/inference/boxes.py

129-129: Use f-string instead of format call (UP032)

Convert to f-string

dreem/datasets/cell_tracking_dataset.py

132-135: Use ternary operator gt_list = self.gt_list[label_idx] if self.gt_list is not None else None instead of if-else-block (SIM108)

Replace if-else-block with gt_list = self.gt_list[label_idx] if self.gt_list is not None else None

dreem/training/losses.py

36-36: Undefined name Frame (F821)

dreem/models/gtr_runner.py

80-80: Undefined name dreem (F821)


81-81: Undefined name dreem (F821)


96-96: Undefined name dreem (F821)


114-114: Undefined name dreem (F821)


132-132: Undefined name dreem (F821)


150-150: Undefined name dreem (F821)


151-151: Undefined name dreem (F821)


168-168: Undefined name dreem (F821)

dreem/inference/metrics.py

16-16: Undefined name dreem (F821)


107-107: Undefined name dreem (F821)


142-142: Loop control variable fidx not used within loop body (B007)

Rename unused fidx to _fidx


230-230: Loop control variable metric_name not used within loop body (B007)

Rename unused metric_name to _metric_name

dreem/inference/track_queue.py

199-202: Use ternary operator vid_name = frame.video if isinstance(frame.video, str) else frame.video.filename instead of if-else-block (SIM108)

Replace if-else-block with vid_name = frame.video if isinstance(frame.video, str) else frame.video.filename


211-211: Use key not in dict instead of key not in dict.keys() (SIM118)

Remove .keys()


254-254: Loop control variable track not used within loop body (B007)

Rename unused track to _track


256-256: Use key not in dict instead of key not in dict.keys() (SIM118)

Remove .keys()

dreem/io/visualize.py

286-286: Loop control variable idx not used within loop body (B007)

Rename unused idx to _idx

dreem/io/association_matrix.py

41-44: Avoid extraneous parentheses (UP034)

Remove extraneous parentheses


60-63: Avoid extraneous parentheses (UP034)

Remove extraneous parentheses


117-117: f-string without any placeholders (F541)

Remove extraneous f prefix


143-143: f-string without any placeholders (F541)

Remove extraneous f prefix


208-208: Loop control variable row_track not used within loop body (B007)

Rename unused row_track to _row_track


209-209: Loop control variable col_track not used within loop body (B007)

Rename unused col_track to _col_track

tests/test_datasets.py

11-11: dreem.models.model_utils.get_device imported but unused (F401)

Remove unused import: dreem.models.model_utils.get_device

dreem/datasets/sleap_dataset.py

150-150: Loop control variable i not used within loop body (B007)

Rename unused i to _i

dreem/models/embedding.py

154-157: Avoid extraneous parentheses (UP034)

Remove extraneous parentheses

dreem/io/config.py

60-60: Undefined name params_cfg (F821)


86-86: Remove quotes from type annotation (UP037)

Remove quotes


86-86: Undefined name GlobalTrackingTransformer (F821)


98-98: Undefined name GTRRunner (F821)


114-114: Remove quotes from type annotation (UP037)

Remove quotes


114-114: Undefined name GTRRunner (F821)


175-175: Remove quotes from type annotation (UP037)

Remove quotes


175-175: Undefined name SleapDataset (F821)


175-175: Remove quotes from type annotation (UP037)

Remove quotes


175-175: Undefined name MicroscopyDataset (F821)


175-175: Remove quotes from type annotation (UP037)

Remove quotes


175-175: Undefined name CellTrackingDataset (F821)


239-239: Remove quotes from type annotation (UP037)

Remove quotes


239-239: Undefined name SleapDataset (F821)


239-239: Remove quotes from type annotation (UP037)

Remove quotes


239-239: Undefined name MicroscopyDataset (F821)


239-239: Remove quotes from type annotation (UP037)

Remove quotes


239-239: Undefined name CellTrackingDataset (F821)


310-310: Remove quotes from type annotation (UP037)

Remove quotes


310-310: Undefined name dreem (F821)


405-409: Use ternary operator trainer_params = self.cfg.trainer if "trainer" in self.cfg else {} instead of if-else-block (SIM108)

Replace if-else-block with trainer_params = self.cfg.trainer if "trainer" in self.cfg else {}

dreem/datasets/data_utils.py

6-6: cElementTree is deprecated, use ElementTree (UP023)

Replace with ElementTree


264-264: Use context handler for opening files (SIM115)


385-388: Use contextlib.suppress(Exception) instead of try-except-pass (SIM105)

Replace with contextlib.suppress(Exception)


387-387: Do not use bare except (E722)

dreem/io/frame.py

61-61: Remove quotes from type annotation (UP037)

Remove quotes


61-61: Undefined name Instance (F821)


62-62: Remove quotes from type annotation (UP037)

Remove quotes


62-62: Undefined name AssociationMatrix (F821)


305-305: Remove quotes from type annotation (UP037)

Remove quotes


305-305: Undefined name Instance (F821)


314-314: Remove quotes from type annotation (UP037)

Remove quotes


314-314: Undefined name Instance (F821)


344-344: Remove quotes from type annotation (UP037)

Remove quotes


344-344: Undefined name AssociationMatrix (F821)


363-363: Remove quotes from type annotation (UP037)

Remove quotes


363-363: Undefined name AssociationMatrix (F821)


556-556: Use key in dict instead of key in dict.keys() (SIM118)

Remove .keys()

dreem/inference/tracker.py

126-126: f-string without any placeholders (F541)

Remove extraneous f prefix


173-173: Loop control variable i not used within loop body (B007)

Rename unused i to _i


177-177: Loop control variable i not used within loop body (B007)

Rename unused i to _i


179-179: Undefined name curr_track (F821)


179-179: Local variable curr_track is assigned to but never used (F841)


434-434: Avoid extraneous parentheses (UP034)

Remove extraneous parentheses

dreem/models/transformer.py

144-144: Undefined name dreem (F821)


145-145: Undefined name dreem (F821)

dreem/io/instance.py

96-96: Undefined name Frame (F821)


215-215: Do not use mutable data structures for argument defaults (B006)

Replace with None; initialize within function


246-246: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)


293-296: Return the condition not self._gt_track_id.shape[0] == 0 directly (SIM103)

Replace with return not self._gt_track_id.shape[0] == 0


325-328: Return the negated condition directly (SIM103)

Inline condition


365-368: Return the condition not self._bbox.shape[1] == 0 directly (SIM103)

Replace with return not self._bbox.shape[1] == 0


435-438: Return the condition not self._crop.shape[-1] == 0 directly (SIM103)

Replace with return not self._crop.shape[-1] == 0


473-476: Return the condition not self._features.shape[-1] == 0 directly (SIM103)

Replace with return not self._features.shape[-1] == 0


523-523: Undefined name Frame (F821)


532-532: Undefined name Frame (F821)

Markdownlint
docs/index.md

20-20: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


21-21: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


21-21: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


25-25: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


25-25: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


26-26: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


26-26: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


27-27: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


27-27: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


31-31: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


31-31: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


35-35: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


35-35: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


39-39: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


39-39: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


21-21: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


25-25: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


26-26: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


31-31: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


22-22: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


24-24: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


28-28: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


30-30: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


32-32: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


34-34: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


36-36: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


38-38: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


40-40: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


40-40: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


42-42: null (MD047, single-trailing-newline)
Files should end with a single newline character

docs/cli.md

47-47: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


13-13: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


35-35: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


56-56: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


104-104: null (MD047, single-trailing-newline)
Files should end with a single newline character

docs/usage.md

49-49: Expected: 0; Actual: 1 (MD007, ul-indent)
Unordered list indentation


50-50: Expected: 0; Actual: 1 (MD007, ul-indent)
Unordered list indentation


10-10: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


49-49: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


61-61: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


71-71: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


152-152: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


159-159: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


160-160: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


165-165: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


173-173: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


175-175: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


200-200: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


218-218: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


234-234: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


255-255: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


4-4: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


14-14: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


15-15: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


15-15: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


21-21: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


21-21: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


27-27: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


27-27: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


36-36: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


46-46: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


53-53: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


53-53: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


63-63: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


126-126: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


132-132: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


145-145: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


179-179: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


184-184: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


185-185: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


185-185: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


195-195: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


240-240: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


252-252: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


252-252: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


15-15: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


21-21: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


63-63: Punctuation: '.' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


66-66: Punctuation: '.' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


106-106: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


240-240: Punctuation: '.' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


17-17: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


19-19: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


23-23: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


25-25: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


29-29: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


31-31: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


74-74: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


116-116: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


120-120: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


156-156: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


166-166: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


168-168: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


170-170: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


172-172: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


203-203: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


247-247: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


249-249: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


251-251: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


74-74: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


203-203: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified

README.md

86-86: Expected: 0; Actual: 1 (MD007, ul-indent)
Unordered list indentation


87-87: Expected: 0; Actual: 1 (MD007, ul-indent)
Unordered list indentation


49-49: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


86-86: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


98-98: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


108-108: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


164-164: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


188-188: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


195-195: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


196-196: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


201-201: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


209-209: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


211-211: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


234-234: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


251-251: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


267-267: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


17-17: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


18-18: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


18-18: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


22-22: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


22-22: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


23-23: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


23-23: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


24-24: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


24-24: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


28-28: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


28-28: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


32-32: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


32-32: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


36-36: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


36-36: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


44-44: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


53-53: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


54-54: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


54-54: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


60-60: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


60-60: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


66-66: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


66-66: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


75-75: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


84-84: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


90-90: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


90-90: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


100-100: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


163-163: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


168-168: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


181-181: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


215-215: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


220-220: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


221-221: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


221-221: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


230-230: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


273-273: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


285-285: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


285-285: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


18-18: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


22-22: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


23-23: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


28-28: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


54-54: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


60-60: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


100-100: Punctuation: '.' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


103-103: Punctuation: '.' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


143-143: Punctuation: ':' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


273-273: Punctuation: '.' (MD026, no-trailing-punctuation)
Trailing punctuation in heading


19-19: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


21-21: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


25-25: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


27-27: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


29-29: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


31-31: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


33-33: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


35-35: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


37-37: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


56-56: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


58-58: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


62-62: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


64-64: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


68-68: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


70-70: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


111-111: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


153-153: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


157-157: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


192-192: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


202-202: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


204-204: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


206-206: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


208-208: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


237-237: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


280-280: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


282-282: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


284-284: null (MD031, blanks-around-fences)
Fenced code blocks should be surrounded by blank lines


47-47: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


77-77: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


86-86: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


165-165: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


223-223: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


233-233: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


252-252: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


37-37: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


111-111: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


237-237: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified

LanguageTool
docs/cli.md

[uncategorized] ~86-~86: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...pecifying each individual +annotate.* param we recommend setting up a visualize con...

docs/usage.md

[uncategorized] ~3-~3: The preposition “through” seems more likely in this position. (AI_EN_LECTOR_REPLACEMENT_PREPOSITION)
Context: ...e a basic workflow from setting up data thru training and running inference. Regardl...


[style] ~3-~3: The word ‘thru’ is informal. Consider replacing it with “through”. (THRU)
Context: ...ference, we recommend at least skimming thru the entire tutorial as there may be use...


[style] ~36-~36: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ... ### Step 1: Generate Ground Truth Data In order to train a model you need 2 things. 1. A ...


[uncategorized] ~37-~37: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...e Ground Truth Data In order to train a model you need 2 things. 1. A video. - F...


[uncategorized] ~41-~41: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...ported file types. - For microscopy data we currently support .tif files. Vide...


[uncategorized] ~47-~47: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...Initial labels To generate your initial labels we recommend a couple methods. - For ...


[grammar] ~47-~47: Using ‘couple’ without ‘of’ is considered to be informal. (PLENTY_OF_NOUNS)
Context: ...rate your initial labels we recommend a couple methods. - For animal pose-estimation, we hig...


[uncategorized] ~49-~49: Write this as one word if you mean the noun “workflow”. (WORK_COMPOUNDS)
Context: ...s://sleap.ai) and running through their work flow. - For microscopy tracking, check out...


[uncategorized] ~52-~52: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ... you'd like to use a different method, (e.g DeepLabCut or ilastik etc), the easiest...


[style] ~52-~52: In American English, abbreviations like “etc.” require a period. (ETC_PERIOD)
Context: ...rent method, (e.g DeepLabCut or ilastik etc), the easiest way to make your data com...


[uncategorized] ~52-~52: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE_2)
Context: ...ively, you can write a custom dataloader but that will take significantly more overh...


[uncategorized] ~54-~54: If this is a compound adjective that modifies the following noun, use a hyphen. (EN_COMPOUND_ADJECTIVE_INTERNAL)
Context: ... thing to train a good model is to have high quality data. In our case good quality means tw...


[typographical] ~54-~54: At the start of a sentence, a comma is usually required for the expression ‘In “our case,”’. (COMMA_OF_IN_PRPS_CASE)
Context: ... model is to have high quality data. In our case good quality means two things: 1. No i...


[style] ~58-~58: To elevate your writing, try using a synonym here. (HARD_TO)
Context: ...o avoid having detection coordinates be hard to distinguish. For instance, with anim...


[uncategorized] ~58-~58: The preposition “in” seems more likely in this position than the preposition “on”. (AI_EN_LECTOR_REPLACEMENT_PREPOSITION_ON_IN)
Context: ... we want to avoid having the key points on two instances. For segmentation, the bo...


[formatting] ~58-~58: Consider inserting a comma before ‘however’. (HOWEVER_MISSING_COMMA)
Context: ...ld be as tight as possible. This may be unavoidable however, in cases of occlusion and overlap. See ...


[uncategorized] ~59-~59: Possible missing preposition found. (AI_EN_LECTOR_MISSING_PREPOSITION)
Context: ... and bad detections. //TODO add example good vs bad detection. We recommend using t...


[style] ~63-~63: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...ting data to a SLEAP compatible format. In order to use the SLEAP gui you'll need to have y...


[uncategorized] ~64-~64: A comma may be missing after the conjunctive/linking adverb ‘Otherwise’. (SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)
Context: ... you can start proofreading right away. Otherwise if you used a different system (e.g Dee...


[uncategorized] ~64-~64: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ...herwise if you used a different system (e.g DeepLabCut) check out [`sleap.io.conver...


[uncategorized] ~64-~64: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... used a different system (e.g DeepLabCut) check out [sleap.io.convert](https://...


[uncategorized] ~64-~64: A punctuation mark might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION)
Context: ... converter from trackmate's output to a .slp](https://gist.github.com/aaprasad/...


[uncategorized] ~64-~64: The grammatical number of this noun doesn’t look right. Consider replacing it. (AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)
Context: ...freading. Once you've ensured that your labels files have no identity switches and you...


[grammar] ~68-~68: Using ‘couple’ without ‘of’ is considered to be informal. (PLENTY_OF_NOUNS)
Context: ...e recommend organizing your data with a couple things in mind. 1. Match video and labels fil...


[uncategorized] ~70-~70: The grammatical number of this noun doesn’t look right. Consider replacing it. (AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)
Context: ...ple things in mind. 1. Match video and labels file stems. Because our dataloaders jus...


[style] ~70-~70: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...lp, file2.slp], [vid1.mp4, vid2.mp4]`). In order to make programmatic file searching easy i...


[uncategorized] ~70-~70: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...der to make programmatic file searching easy its best to save your labels and vid fi...


[uncategorized] ~70-~70: “its” (belonging to it) seems less likely than “it’s” (it is) (AI_HYDRA_LEO_CPT_ITS_ITIS)
Context: ...o make programmatic file searching easy its best to save your labels and vid files ...


[style] ~70-~70: ‘vid’ is informal. Consider replacing it. (VID)
Context: ...g easy its best to save your labels and vid files with the same stem so that you ca...


[uncategorized] ~70-~70: “its” (belonging to it) seems less likely than “it’s” (it is) (AI_HYDRA_LEO_CPT_ITS_ITIS)
Context: ...ensure the ordering will be consistent. Its also just best practice so you know whi...


[uncategorized] ~70-~70: It seems likely that a singular genitive (’s) apostrophe is missing. (AI_HYDRA_LEO_APOSTROPHE_S_XS)
Context: ...best practice so you know which video a labels file corresponds to. 2. Store correspon...


[style] ~104-~104: Consider replacing this word to strengthen your wording. (AND_THAT)
Context: ...train script if you're an advanced user and would like to have some additional flex...


[uncategorized] ~108-~108: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...set of parameters when training (for an example see [here](configs/training.md#override...


[uncategorized] ~119-~119: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... > Note: you can use relative paths as well but may be a bit riskier so we recommen...


[uncategorized] ~124-~124: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...


[grammar] ~139-~139: It seems like one article is redundant in this context. (A_RB_A_JJ_NN)
Context: .../dreem_configs` directory that contains a only a small selection of parameters that I'd like t...


[uncategorized] ~146-~146: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...g a specific param via the command line directly you can use the section.param=key syn...


[uncategorized] ~151-~151: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ...E_CONFIG_STEM] section.param=value ``` e.g If now I want to override a couple para...


[grammar] ~152-~152: Using ‘couple’ without ‘of’ is considered to be informal. (PLENTY_OF_NOUNS)
Context: ...ue ``` e.g If now I want to override a couple parameters again, say change the number of attenti...


[grammar] ~158-~158: The verb “add” needs to be in the to-infinitive form. (MISSING_TO_BEFORE_A_VERB)
Context: ...wise an error will be thrown > if you'd like add a new parameter you can add ++ to the...


[uncategorized] ~159-~159: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...arameter exists, otherwise create a new one you can add a single + to the front o...


[typographical] ~160-~160: The word “otherwise” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence. (THUS_SENTENCE)
Context: ...t to make sure you've matched the param exactly, otherwise it will simply add a new parameter with...


[uncategorized] ~161-~161: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ...and the original value won't change. > e.g doing model.n_head=3 will cause the o...


[uncategorized] ~165-~165: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...d the direct override or the file-based override however you can technically do both via...


[uncategorized] ~175-~175: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ...g CLI and file-based override syntax > (e.g make sure section.param doesn't appea...


[style] ~186-~186: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...estimators/segementors. This means that in order to run inference(tracking) with our model ...


[uncategorized] ~186-~186: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...der to run inference(tracking) with our model you need 3 things. 1. A pretrained mod...


[uncategorized] ~191-~191: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...ported file types. - For microscopy data we currently support .tif files. Vide...


[style] ~192-~192: Did you mean ‘different from’? ‘Different than’ is often considered colloquial style. (DIFFERENT_THAN)
Context: ... This labels file is slightly different than in training because we only need detect...


[uncategorized] ~192-~192: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...ing because we only need detections for tracking since the tracks will of course come fr...


[typographical] ~192-~192: Consider adding two commas here. (OF_COURSE_COMMA)
Context: ...tions for tracking since the tracks will of course come from our model predictions. We st...


[uncategorized] ~194-~194: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...g SLEAP and TrackMate to generate these labels however this time you would only need t...


[uncategorized] ~194-~194: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...d your detections if you'd like to. For TrackMate we recommend using the "spots table" la...


[uncategorized] ~199-~199: The grammatical number of this noun doesn’t look right. Consider replacing it. (AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)
Context: ... used for training. 1. Match video and labels file stems. Because our dataloaders jus...


[style] ~199-~199: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...lp, file2.slp], [vid1.mp4, vid2.mp4]`). In order to make programmatic file searching easy i...


[uncategorized] ~199-~199: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...der to make programmatic file searching easy its best to save your labels and vid fi...


[uncategorized] ~199-~199: “its” (belonging to it) seems less likely than “it’s” (it is) (AI_HYDRA_LEO_CPT_ITS_ITIS)
Context: ...o make programmatic file searching easy its best to save your labels and vid files ...


[style] ~199-~199: ‘vid’ is informal. Consider replacing it. (VID)
Context: ...g easy its best to save your labels and vid files with the same stem so that you ca...


[uncategorized] ~199-~199: “its” (belonging to it) seems less likely than “it’s” (it is) (AI_HYDRA_LEO_CPT_ITS_ITIS)
Context: ...ensure the ordering will be consistent. Its also just best practice so you know whi...


[uncategorized] ~199-~199: It seems likely that a singular genitive (’s) apostrophe is missing. (AI_HYDRA_LEO_APOSTROPHE_S_XS)
Context: ...best practice so you know which video a labels file corresponds to. 2. Store correspon...


[misspelling] ~219-~219: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’. (EN_A_VS_AN)
Context: ...et up a config file that specifies 1. a ckpt_path 2. a out_dir 3. a `Tracke...


[misspelling] ~220-~220: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’. (EN_A_VS_AN)
Context: ...le that specifies 1. a ckpt_path 2. a out_dir 3. a Tracker config 4. a `d...


[uncategorized] ~228-~228: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...e. ### Step 3 Run Inference Just like training we can use the hydra syntax for specify...


[uncategorized] ~228-~228: A comma may be missing after the conjunctive/linking adverb ‘Thus’. (SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)
Context: ...x for specifying arguments via the cli. Thus you can run inference via: ```bash dre...


[uncategorized] ~241-~241: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE)
Context: ...ased override rather than the file based but you're more than welcome to do so. In ...


[style] ~242-~242: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...but you're more than welcome to do so. In order to override params via the CLI, we can use...


[uncategorized] ~247-~247: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ...[CONFIG_STEM] section.param=[VALUE] ``` e.g if I want to set the window size of the...


[typographical] ~253-~253: The word “otherwise” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence. (THUS_SENTENCE)
Context: ...pecified in the config it will save to ./[OUTDIR]/[VID_NAME].dreem_inference.slp, otherwise it will just save to `./results/[VID_NA...

README.md

[style] ~43-~43: The word ‘thru’ is informal. Consider replacing it with “through”. (THRU)
Context: ...e a basic workflow from setting up data thru training and running inference. Regardl...


[uncategorized] ~43-~43: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...ta thru training and running inference. Regardless if you're only interested in running in...


[style] ~43-~43: The word ‘thru’ is informal. Consider replacing it with “through”. (THRU)
Context: ...ference, we recommend at least skimming thru the entire tutorial as there may be use...


[uncategorized] ~51-~51: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ... respective docs to get some familiarity but is not necessary. ### Setup #### Step ...


[style] ~75-~75: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...#### Step 1: Generate Ground Truth Data In order to train a model you need 2 things. 1. A v...


[uncategorized] ~76-~76: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...e Ground Truth Data In order to train a model you need 2 things. 1. A video. - Fo...


[uncategorized] ~78-~78: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ... 2 things. 1. A video. - For animal data see the [imageio](https://imageio.rea...


[uncategorized] ~79-~79: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...ported file types. - For microscopy data we currently support .tif files. Vide...


[uncategorized] ~85-~85: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...Initial labels To generate your initial labels we recommend a couple methods. - For a...


[grammar] ~85-~85: Using ‘couple’ without ‘of’ is considered to be informal. (PLENTY_OF_NOUNS)
Context: ...rate your initial labels we recommend a couple methods. - For animal pose-estimation, we high...


[uncategorized] ~86-~86: Write this as one word if you mean the noun “workflow”. (WORK_COMPOUNDS)
Context: ...s://sleap.ai) and running through their work flow. - For microscopy tracking, check out...


[uncategorized] ~89-~89: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ... you'd like to use a different method, (e.g DeepLabCut or ilastik etc), the easiest...


[style] ~89-~89: In American English, abbreviations like “etc.” require a period. (ETC_PERIOD)
Context: ...rent method, (e.g DeepLabCut or ilastik etc), the easiest way to make your data com...


[uncategorized] ~89-~89: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE_2)
Context: ...ively, you can write a custom dataloader but that will take significantly more overh...


[uncategorized] ~91-~91: If this is a compound adjective that modifies the following noun, use a hyphen. (EN_COMPOUND_ADJECTIVE_INTERNAL)
Context: ... thing to train a good model is to have high quality data. In our case good quality means tw...


[typographical] ~91-~91: At the start of a sentence, a comma is usually required for the expression ‘In “our case,”’. (COMMA_OF_IN_PRPS_CASE)
Context: ... model is to have high quality data. In our case good quality means two things: 1. No i...


[style] ~95-~95: To elevate your writing, try using a synonym here. (HARD_TO)
Context: ...o avoid having detection coordinates be hard to distinguish. For instance, with anim...


[formatting] ~95-~95: Consider inserting a comma before ‘however’. (HOWEVER_MISSING_COMMA)
Context: ...ld be as tight as possible. This may be unavoidable however, in cases of occlusion and overlap. See ...


[style] ~100-~100: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...ting data to a SLEAP compatible format. In order to use the SLEAP gui you'll need to have y...


[uncategorized] ~101-~101: A comma may be missing after the conjunctive/linking adverb ‘Otherwise’. (SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)
Context: ... you can start proofreading right away. Otherwise if you used a different system (e.g Dee...


[uncategorized] ~101-~101: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ...herwise if you used a different system (e.g DeepLabCut) check out [`sleap.io.conver...


[grammar] ~105-~105: Using ‘couple’ without ‘of’ is considered to be informal. (PLENTY_OF_NOUNS)
Context: ...e recommend organizing your data with a couple things in mind. 1. Match video and labels fil...


[style] ~107-~107: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...lp, file2.slp], [vid1.mp4, vid2.mp4]`). In order to make programmatic file searching easy i...


[uncategorized] ~107-~107: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...der to make programmatic file searching easy its best to save your labels and vid fi...


[uncategorized] ~107-~107: “its” (belonging to it) seems less likely than “it’s” (it is) (AI_HYDRA_LEO_CPT_ITS_ITIS)
Context: ...o make programmatic file searching easy its best to save your labels and vid files ...


[style] ~107-~107: ‘vid’ is informal. Consider replacing it. (VID)
Context: ...g easy its best to save your labels and vid files with the same stem so that you ca...


[uncategorized] ~107-~107: “its” (belonging to it) seems less likely than “it’s” (it is) (AI_HYDRA_LEO_CPT_ITS_ITIS)
Context: ...ensure the ordering will be consistent. Its also just best practice so you know whi...


[uncategorized] ~107-~107: It seems likely that a singular genitive (’s) apostrophe is missing. (AI_HYDRA_LEO_APOSTROPHE_S_XS)
Context: ...best practice so you know which video a labels file corresponds to. 2. Store correspon...


[style] ~141-~141: Consider replacing this word to strengthen your wording. (AND_THAT)
Context: ...train script if you're an advanced user and would like to have some additional flex...


[grammar] ~145-~145: The word “checkout” is a noun. The verb is spelled with a space. (NOUN_VERB_CONFUSION)
Context: ... parameters needed for training. Please checkout the [README](dreem/training/configs/R...


[uncategorized] ~156-~156: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...nside my /home/aaprasad/dreem_configs directory I can call ```bash dreem-train --config...


[uncategorized] ~161-~161: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...relative paths as well but may be a bit riskier so we recommend absolute paths whenever...


[grammar] ~175-~175: It seems like one article is redundant in this context. (A_RB_A_JJ_NN)
Context: .../dreem_configs` directory that contains a only a small selection of parameters that I'd like t...


[uncategorized] ~187-~187: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ...E_CONFIG_STEM] section.param=value ``` e.g If now I want to override a couple para...


[grammar] ~188-~188: Using ‘couple’ without ‘of’ is considered to be informal. (PLENTY_OF_NOUNS)
Context: ...ue ``` e.g If now I want to override a couple parameters again, say change the number of attenti...


[grammar] ~194-~194: The verb “add” needs to be in the to-infinitive form. (MISSING_TO_BEFORE_A_VERB)
Context: ...wise an error will be thrown > if you'd like add a new parameter you can add ++ to the...


[typographical] ~196-~196: The word “otherwise” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence. (THUS_SENTENCE)
Context: ...t to make sure you've matched the param exactly, otherwise it will simply add a new parameter with...


[uncategorized] ~197-~197: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ...and the original value won't change. > e.g doing model.n_head=3 will cause the o...


[uncategorized] ~211-~211: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ...g CLI and file-based override syntax > (e.g make sure section.param doesn't appea...


[uncategorized] ~222-~222: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...tem is that we decouple detection and tracking so you can use off-the-shelf high perfo...


[style] ~222-~222: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...estimators/segementors. This means that in order to run inference(tracking) with our model ...


[uncategorized] ~225-~225: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...kpt file. 2. A video. - For animal data see the [imageio`](https://imageio.rea...


[uncategorized] ~226-~226: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...ported file types. - For microscopy data we currently support .tif files. Vide...


[style] ~227-~227: Did you mean ‘different from’? ‘Different than’ is often considered colloquial style. (DIFFERENT_THAN)
Context: ... This labels file is slightly different than in training because we only need detect...


[typographical] ~227-~227: Consider adding two commas here. (OF_COURSE_COMMA)
Context: ...tions for tracking since the tracks will of course come from our model predictions. We st...


[style] ~233-~233: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...lp, file2.slp], [vid1.mp4, vid2.mp4]`). In order to make programmatic file searching easy i...


[uncategorized] ~233-~233: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...der to make programmatic file searching easy its best to save your labels and vid fi...


[uncategorized] ~233-~233: “its” (belonging to it) seems less likely than “it’s” (it is) (AI_HYDRA_LEO_CPT_ITS_ITIS)
Context: ...o make programmatic file searching easy its best to save your labels and vid files ...


[style] ~233-~233: ‘vid’ is informal. Consider replacing it. (VID)
Context: ...g easy its best to save your labels and vid files with the same stem so that you ca...


[uncategorized] ~233-~233: “its” (belonging to it) seems less likely than “it’s” (it is) (AI_HYDRA_LEO_CPT_ITS_ITIS)
Context: ...ensure the ordering will be consistent. Its also just best practice so you know whi...


[uncategorized] ~233-~233: It seems likely that a singular genitive (’s) apostrophe is missing. (AI_HYDRA_LEO_APOSTROPHE_S_XS)
Context: ...best practice so you know which video a labels file corresponds to. 2. Store correspon...


[misspelling] ~252-~252: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’. (EN_A_VS_AN)
Context: ...set up a config file that specifies 1. a ckpt_path 2. a out_dir 3. a `Tracke...


[misspelling] ~253-~253: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’. (EN_A_VS_AN)
Context: ...ile that specifies 1. a ckpt_path 2. a out_dir 3. a Tracker config 4. a `d...


[uncategorized] ~261-~261: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: .... #### Step 3 Run Inference Just like training we can use the hydra syntax for specify...


[uncategorized] ~261-~261: A comma may be missing after the conjunctive/linking adverb ‘Thus’. (SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)
Context: ...x for specifying arguments via the cli. Thus you can run inference via: ```bash dre...


[uncategorized] ~274-~274: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE)
Context: ...ased override rather than the file based but you're more than welcome to do so. In ...


[style] ~275-~275: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...but you're more than welcome to do so. In order to override params via the CLI, we can use...


[uncategorized] ~280-~280: The abbreviation “e.g.” (= for example) requires two periods. (E_G)
Context: ...[CONFIG_STEM] section.param=[VALUE] ``` e.g if I want to set the window size of the...


[typographical] ~286-~286: The word “otherwise” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence. (THUS_SENTENCE)
Context: ...pecified in the config it will save to ./[OUTDIR]/[VID_NAME].dreem_inference.slp, otherwise it will just save to `./results/[VID_NA...

Additional comments not posted (52)
environment_osx-arm64.yml (1)

9-9: Ensure compatibility with Python 3.11 for all dependencies.

environment_cpu.yml (1)

10-10: Ensure compatibility with Python 3.11 for all dependencies, especially conda-forge::opencv <4.9.0.

docs/index.md (1)

5-5: Added GitHub stars badge to enhance the visibility and credibility of the project.

pyproject.toml (1)

21-22: Updated Python version classifiers to include Python 3.10 and 3.11.

dreem/datasets/eval_dataset.py (1)

28-28: Updated the __getitem__ method to handle merging of ground truth and predicted datasets. Ensure that the error handling for index mismatches is robust.

dreem/io/track.py (2)

3-3: Added from __future__ import annotations to use postponed evaluation of annotations.


80-80: Updated the __getitem__ method to handle both single and list indices. Ensure that the type checking is robust and consider adding more specific error messages.

Tools
Ruff

80-80: Remove quotes from type annotation (UP037)

Remove quotes


80-80: Undefined name Instance (F821)


80-80: Remove quotes from type annotation (UP037)

Remove quotes


80-80: Undefined name Instance (F821)

dreem/training/train.py (2)

18-20: Logging setup looks good and follows best practices.


49-50: Good use of logging for debugging.

dreem/inference/track.py (2)

14-16: Logging setup looks good and follows best practices.


81-81: Ensure proper logging of video information.

dreem/models/visual_encoder.py (3)

3-3: Import statements are organized and clear.


27-27: Proper use of type hints and default arguments in constructor.


60-60: Ensure that the feature extractor selection handles different backends correctly.

dreem/models/global_tracking_transformer.py (1)

Line range hint 15-26: Proper use of type hints and default arguments in constructor.

dreem/models/gtr_runner.py (3)

14-14: Logger setup is appropriate for the module scope.


204-207: Excellent use of logging for exception handling. This will aid in debugging by providing context about the failure.


36-42: Ensure that the type annotations are consistent across the project, especially for dictionary types.

dreem/inference/metrics.py (2)

7-7: Logger setup is appropriate for the module scope.


45-46: Good use of logging to handle cases where no instances are detected.

dreem/inference/track_queue.py (2)

7-7: Logger setup is appropriate for the module scope.


181-181: Proper use of logging to handle exceptions when a track ID is not found in the queue.

dreem/io/visualize.py (2)

14-14: Logger setup is appropriate for the module scope.


328-330: Effective logging for success and error scenarios in video annotation.

dreem/io/association_matrix.py (3)

7-7: Logging module imported for better logging practices.


24-24: Updated type annotations using modern Python syntax for union types.


Line range hint 226-251: Improved error handling by logging exceptions before re-raising them.

dreem/datasets/sleap_dataset.py (2)

9-9: Logging module imported for better logging practices.


26-33: Updated type annotations using modern Python syntax for union types and added more descriptive comments for parameters.

dreem/models/embedding.py (1)

5-5: Logging module imported for better logging practices.

dreem/io/config.py (4)

52-52: This method correctly implements configuration loading from YAML files.


76-76: Proper handling of empty or None hyperparameters with appropriate logging.


162-168: Proper use of globbing to retrieve data paths and appropriate logging of the process.


19-19: Consider initializing params_cfg in the method signature to ensure it's defined before use.

- def __init__(self, cfg: DictConfig, params_cfg: DictConfig | None = None):
+ def __init__(self, cfg: DictConfig, params_cfg: DictConfig | None = None):

Likely invalid or redundant comment.

docs/usage.md (2)

115-115: Ensure consistency in command examples and clarify the use of hydra override syntax.

Also applies to: 121-121, 136-136, 142-142, 149-149, 155-155, 167-167, 171-171


231-231: Review the command syntax for dreem-track to ensure it aligns with the project's standards.

Also applies to: 237-237, 246-246, 250-250

Verification successful

The command syntax for dreem-track in the docs/usage.md file appears consistent across multiple instances. Each instance follows the pattern dreem-track --config-base=[CONFIG_DIR] --config-name=[CONFIG_STEM] with additional parameters as needed.

  • Line 231: dreem-track --config-base=[CONFIG_DIR] --config-name=[CONFIG_STEM]
  • Line 237: dreem-track --config-base=/home/aaprasad/dreem_configs --config-name=track
  • Line 246: dreem-track --config-base=[CONFIG_DIR] --config-name=[CONFIG_STEM] section.param=[VALUE]
  • Line 250: dreem-track --config-base=/home/aaprasad/dreem_configs --config-name=track ckpt_path="/home/aaprasad/models/new_best.ckpt" tracker.window_size=32

The syntax is consistent and aligns with the project's standards.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Check for consistency in the command syntax for `dreem-track`.
grep 'dreem-track --config-base=' docs/usage.md

Length of output: 427

dreem/io/frame.py (4)

12-12: Logger setup looks good and follows best practices.


15-15: The function _to_tensor is well-documented and correctly handles different data types. Good use of type annotations.


100-100: The method to is well-implemented with comprehensive handling of different types and properties. Good use of type annotations and device handling.


135-137: The method from_slp is well-documented and correctly converts sio.LabeledFrame to dreem.io.Frame. The use of unpacking in img_shape is a nice touch for handling different dimensions.

dreem/inference/tracker.py (4)

5-5: Import of logging module is appropriate for the logging improvements described in the PR.


15-16: Initialization of logger is correctly done at the module level, which is a good practice for centralized logging.


27-29: The use of union types with | for optional parameters is a modern Python feature that enhances readability and type clarity.


153-153: The addition of debug logging statements is a good practice for tracing and diagnosing issues during development and maintenance phases.

Also applies to: 159-159, 168-170, 243-243, 251-251, 293-295, 334-335, 448-450, 453-453, 456-456

dreem/models/transformer.py (2)

42-42: The addition of embedding_meta and related logic for handling positional embeddings is a significant enhancement, allowing for more flexible configuration of the model.


145-145: The type hint for query_instances now correctly allows for None as a valid type, aligning with the function's capability to handle cases where no query instances are provided.

Tools
Ruff

145-145: Undefined name dreem (F821)

dreem/io/instance.py (6)

7-7: Ensure that the logging module is used consistently throughout the file for debugging and error messages.


9-9: The use of Self from typing is appropriate for methods that return an instance of the class they are defined in.


11-11: Proper initialization of the logger for this module. Good practice for consistent logging.


14-14: The _to_tensor function is well-documented and handles different types of input correctly.


92-92: The use of union types for optional fields is a good practice for clarity and type safety.

Also applies to: 93-93, 95-95


137-137: The to method is well-implemented, ensuring the instance can be moved to a different device or dtype efficiently.

print(asso_output)
print(traj_score)
raise (e)
match_i, match_j = linear_sum_assignment((-traj_score))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extraneous parentheses to improve readability.

- match_i, match_j = linear_sum_assignment((-traj_score))
+ match_i, match_j = linear_sum_assignment(-traj_score)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
match_i, match_j = linear_sum_assignment((-traj_score))
match_i, match_j = linear_sum_assignment(-traj_score)
Tools
Ruff

434-434: Avoid extraneous parentheses (UP034)

Remove extraneous parentheses

@@ -120,8 +123,7 @@ def track(
instances_pred = self.sliding_inference(model, frames)

if not self.persistent_tracking:
if self.verbose:
warnings.warn(f"Clearing Queue after tracking")
logger.debug(f"Clearing Queue after tracking")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary f prefix from the debug log statement as it does not contain any placeholders.

- logger.debug(f"Clearing Queue after tracking")
+ logger.debug("Clearing Queue after tracking")
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.debug(f"Clearing Queue after tracking")
logger.debug("Clearing Queue after tracking")
Tools
Ruff

126-126: f-string without any placeholders (F541)

Remove extraneous f prefix


logger.debug(
f"Initializing track on clip ind {batch_idx} frame {frame_to_track.frame_id.item()}"
)

curr_track_id = 0
for i, instance in enumerate(frames[batch_idx].instances):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loop control variables i are not used within the loop body. Consider renaming them to _i to indicate that they are intentionally unused.

- for i, instance in enumerate(frames[batch_idx].instances):
+ for _i, instance in enumerate(frames[batch_idx].instances):

Also applies to: 177-177

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for i, instance in enumerate(frames[batch_idx].instances):
for _i, instance in enumerate(frames[batch_idx].instances):
Tools
Ruff

173-173: Loop control variable i not used within loop body (B007)

Rename unused i to _i

@@ -237,7 +240,7 @@ def to_slp(
track_lookup,
)
except Exception as e:
print(
logger.exception(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use raise ... from e to provide more context about the exception chain.

-            raise RuntimeError(f"Failed to convert to sio.PredictedInstance: {e}")
+            raise RuntimeError(f"Failed to convert to sio.PredictedInstance: {e}") from e
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.exception(
raise RuntimeError(f"Failed to convert to sio.PredictedInstance: {e}") from e

@@ -16,3 +17,18 @@
# from .training import run

from dreem.inference.tracker import Tracker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused import dreem.inference.tracker.Tracker.

- from dreem.inference.tracker import Tracker
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from dreem.inference.tracker import Tracker
Tools
Ruff

19-19: dreem.inference.tracker.Tracker imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

@@ -1,5 +1,6 @@
"""Top-level package for dreem."""

import logging.config
from dreem.version import __version__
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused import dreem.version.__version__.

- from dreem.version import __version__
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from dreem.version import __version__
Tools
Ruff

4-4: dreem.version.__version__ imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)

logging_cfg = yaml.load(stream, Loader=yaml.FullLoader)

logging.config.dictConfig(logging_cfg)
logger = logging.getLogger("dreem")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove assignment to unused variable logger.

- logger = logging.getLogger("dreem")
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger = logging.getLogger("dreem")
Tools
Ruff

34-34: Local variable logger is assigned to but never used (F841)

Remove assignment to unused variable logger

@@ -1,5 +1,6 @@
"""Top-level package for dreem."""

import logging.config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused import logging.config.

- import logging.config
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import logging.config
Tools
Ruff

3-3: logging.config imported but unused; consider removing, adding to __all__, or using a redundant alias (F401)


package_directory = os.path.dirname(os.path.abspath(__file__))

with open(os.path.join(package_directory, "..", "logging.yaml"), "r") as stream:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary open mode parameters from the file open function.

- with open(os.path.join(package_directory, "..", "logging.yaml"), "r") as stream:
+ with open(os.path.join(package_directory, "..", "logging.yaml")) as stream:
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
with open(os.path.join(package_directory, "..", "logging.yaml"), "r") as stream:
with open(os.path.join(package_directory, "..", "logging.yaml")) as stream:
Tools
Ruff

30-30: Unnecessary open mode parameters (UP015)

Remove open mode parameters

Comment on lines +119 to +120
logger.info(f"Using the following params for tracker:")
logger.info(model.tracker_cfg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extraneous f prefix from logging statement.

- logger.info(f"Using the following params for tracker:")
+ logger.info("Using the following params for tracker:")
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.info(f"Using the following params for tracker:")
logger.info(model.tracker_cfg)
logger.info("Using the following params for tracker:")
logger.info(model.tracker_cfg)
Tools
Ruff

119-119: f-string without any placeholders (F541)

Remove extraneous f prefix

@aaprasad aaprasad requested a review from talmo June 12, 2024 22:01
Base automatically changed from aadi/update-python-version to main July 22, 2024 23:08
… of `typing.Union` and referring to standard collections directly rather than `typing.Collection`
* replace print statements and warnings with logger emissions
* get rid of unnecessary/commented out exceptions/print statements
@aaprasad aaprasad merged commit 29e43de into main Jul 22, 2024
3 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Outside diff range, codebase verification and nitpick comments (1)
dreem/inference/track.py (1)

117-120: Remove extraneous f prefix from logging statement.

The f prefix is unnecessary in the logging statement.

- logger.info(f"Using the following params for tracker:")
+ logger.info("Using the following params for tracker:")
Tools
Ruff

119-119: f-string without any placeholders

Remove extraneous f prefix

(F541)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6ea1060 and 978942f.

Files selected for processing (21)
  • dreem/init.py (2 hunks)
  • dreem/datasets/data_utils.py (2 hunks)
  • dreem/datasets/microscopy_dataset.py (1 hunks)
  • dreem/datasets/sleap_dataset.py (2 hunks)
  • dreem/inference/metrics.py (3 hunks)
  • dreem/inference/track.py (5 hunks)
  • dreem/inference/track_queue.py (5 hunks)
  • dreem/inference/tracker.py (10 hunks)
  • dreem/io/association_matrix.py (2 hunks)
  • dreem/io/config.py (5 hunks)
  • dreem/io/frame.py (3 hunks)
  • dreem/io/instance.py (3 hunks)
  • dreem/io/visualize.py (5 hunks)
  • dreem/models/embedding.py (2 hunks)
  • dreem/models/gtr_runner.py (2 hunks)
  • dreem/models/model_utils.py (1 hunks)
  • dreem/training/init.py (1 hunks)
  • dreem/training/losses.py (1 hunks)
  • dreem/training/train.py (4 hunks)
  • logging.yaml (1 hunks)
  • tests/test_datasets.py (1 hunks)
Files skipped from review due to trivial changes (3)
  • dreem/datasets/data_utils.py
  • dreem/datasets/microscopy_dataset.py
  • tests/test_datasets.py
Additional context used
yamllint
logging.yaml

[error] 36-36: trailing spaces

(trailing-spaces)

Ruff
dreem/__init__.py

3-3: logging.config imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


34-34: Local variable logger is assigned to but never used

Remove assignment to unused variable logger

(F841)

dreem/inference/track.py

119-119: f-string without any placeholders

Remove extraneous f prefix

(F541)

dreem/inference/tracker.py

126-126: f-string without any placeholders

Remove extraneous f prefix

(F541)

Additional comments not posted (61)
dreem/training/__init__.py (1)

1-1: Verify the impact of removing the train import.

The train function import has been removed. Ensure that this change does not break any existing functionality and that users are informed of how to access the train functionality if it has been moved.

dreem/__init__.py (6)

3-3: Remove unused import logging.config.

The logging.config import is unused and should be removed.

Tools
Ruff

3-3: logging.config imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


4-4: Remove unused import dreem.version.__version__.

The __version__ import is unused and should be removed.

Tools
Ruff

4-4: dreem.version.__version__ imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


19-19: Remove unused import dreem.inference.tracker.Tracker.

The Tracker import is unused and should be removed.

Tools
Ruff

19-19: dreem.inference.tracker.Tracker imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


30-30: Remove unnecessary open mode parameters from the file open function.

The open mode parameters are unnecessary and should be removed.


34-34: Remove assignment to unused variable logger.

The logger variable is assigned but never used.

Tools
Ruff

34-34: Local variable logger is assigned to but never used

Remove assignment to unused variable logger

(F841)


22-34: LGTM! The setup_logging function is a good addition.

The new setup_logging function is well-implemented and enhances the logging capabilities.

Tools
Ruff

34-34: Local variable logger is assigned to but never used

Remove assignment to unused variable logger

(F841)

dreem/training/train.py (3)

49-53: LGTM!

The changes improve the logging mechanism by replacing print statements with logger.debug and logger.info calls.


Line range hint 78-90:
LGTM!

The change in the logger variable name from logger to run_logger helps avoid potential conflicts and provides clearer context.


18-20: Verify logger configuration.

Ensure that the logger is properly configured with appropriate handlers and formatters.

dreem/inference/track.py (4)

81-81: LGTM!

The changes improve the logging mechanism by replacing print statements with logger.info calls.


108-108: LGTM!

The changes improve the logging mechanism by replacing print statements with logger.info calls.


141-141: LGTM!

The changes improve the logging mechanism by replacing print statements with logger.info calls.


14-16: Verify logger configuration.

Ensure that the logger is properly configured with appropriate handlers and formatters.

dreem/models/gtr_runner.py (3)

5-5: LGTM!

The import statement for the logging module is necessary for adding logging functionality.


14-14: LGTM!

The logger instance is correctly initialized for logging messages.


204-207: LGTM! But verify logger configuration.

The added logging for exceptions improves traceability and debugging. Ensure that the logger is properly configured to capture and store these logs.

dreem/inference/metrics.py (3)

7-7: LGTM!

The import statement for the logging module is necessary for adding logging functionality.


10-10: LGTM!

The logger instance is correctly initialized for logging messages.


45-46: LGTM!

The added debug log statement improves observability without altering the core logic.

dreem/inference/track_queue.py (5)

7-10: LGTM! Logger initialization is correct.

The logger is correctly initialized for the dreem.inference namespace.


181-181: LGTM! Exception handling with logger is appropriate.

The use of logger.exception() provides a detailed stack trace, which is useful for debugging.


217-219: LGTM! Debug logging is appropriate.

The use of logger.debug() for logging the creation of a new track is appropriate for debug-level information.


293-295: LGTM! Debug logging is appropriate.

The use of logger.debug() for logging the gap increment information is appropriate for debug-level information.


305-307: LGTM! Debug logging is appropriate.

The use of logger.debug() for logging the termination of a track is appropriate for debug-level information.

dreem/io/visualize.py (3)

14-16: LGTM! Logger initialization is correct.

The logger is correctly initialized for the dreem.io namespace.


267-267: LGTM! Exception handling with logger is appropriate.

The use of logger.exception() provides a detailed stack trace, which is useful for debugging.


328-330: LGTM! Info and error logging are appropriate.

The use of logger.info() for logging success and logger.error() for logging failure is appropriate for information and error-level messages.

dreem/io/association_matrix.py (2)

7-12: LGTM! Logger initialization is correct.

The logger is correctly initialized for the dreem.io namespace.


247-251: LGTM! Exception handling with logger is appropriate.

The use of logger.exception() provides a detailed stack trace, which is useful for debugging.

dreem/datasets/sleap_dataset.py (3)

9-9: LGTM! Import statement changes are correct.

The logging module is correctly imported, and the unused warnings module is removed.


14-14: LGTM! Logger instance creation is correct.

The logger instance for the dreem.datasets namespace is correctly created.


170-172: LGTM! Logging warning is correctly implemented.

The print statement is correctly replaced with a logging warning, enhancing error handling.

dreem/models/embedding.py (3)

5-5: LGTM! Import statement changes are correct.

The logging module is correctly imported.


8-8: LGTM! Logger instance creation is correct.

The logger instance for the dreem.models namespace is correctly created.


287-290: LGTM! Logging exception is correctly implemented.

The print statement is correctly replaced with logging calls that use logger.exception, enhancing error handling.

dreem/io/config.py (10)

8-8: LGTM! Import statement changes are correct.

The logging module is correctly imported.


13-13: LGTM! Logger instance creation is correct.

The logger instance for the dreem.io namespace is correctly created.


31-31: LGTM! Logging info is correctly implemented.

The print statement is correctly replaced with logger.info, enhancing logging practices.


37-37: LGTM! Logging info is correctly implemented.

The print statement is correctly replaced with logger.info, enhancing logging practices.


76-76: LGTM! Logging warning is correctly implemented.

The print statement is correctly replaced with logger.warning, enhancing logging practices.


82-82: LGTM! Logging exception is correctly implemented.

The print statement is correctly replaced with logger.exception, enhancing error handling.


164-164: LGTM! Logging debug is correctly implemented.

The print statement is correctly replaced with logger.debug, enhancing logging practices.


166-166: LGTM! Logging debug is correctly implemented.

The print statement is correctly replaced with logger.debug, enhancing logging practices.


168-168: LGTM! Logging debug is correctly implemented.

The print statement is correctly replaced with logger.debug, enhancing logging practices.


366-366: LGTM! Logging exception is correctly implemented.

The print statement is correctly replaced with logger.exception, enhancing error handling.

dreem/io/frame.py (2)

417-419: Enhanced error logging with logger.exception.

The use of logger.exception improves error handling by logging the exception details, which is a best practice for maintainability and debuggability.


517-518: Simplified get_crops method.

The removal of the try-except block and directly returning the concatenated tensor simplifies the method, assuming the presence of instances is already verified by has_instances.

dreem/inference/tracker.py (11)

126-127: Improved logging in track method.

The use of logger.debug to log the message about clearing the queue after tracking improves logging practices.

Tools
Ruff

126-126: f-string without any placeholders

Remove extraneous f prefix

(F541)


153-159: Improved logging in sliding_inference method.

The use of logger.debug to log messages about the current number of tracks and the resetting of the track queue improves logging practices.


167-170: Improved logging in sliding_inference method.

The use of logger.debug to log messages about initializing tracks improves logging practices.


243-243: Improved logging in _run_global_tracker method.

The use of logger.debug to log the frame ID improves logging practices.


251-251: Improved logging in _run_global_tracker method.

The use of logger.debug to log the total number of instances improves logging practices.


293-295: Improved logging in _run_global_tracker method.

The use of logger.debug to log the number of non-query and query instances improves logging practices.


334-335: Improved logging in _run_global_tracker method.

The use of logger.debug to log instance IDs and unique IDs improves logging practices.


448-450: Improved logging in _run_global_tracker method.

The use of logger.debug to log the assignment of instances to tracks improves logging practices.


453-456: Improved logging in _run_global_tracker method.

The use of logger.debug to log the creation of new tracks improves logging practices.


434-434: Remove extraneous parentheses to improve readability.

Remove the extraneous parentheses around -traj_score to improve readability.

- match_i, match_j = linear_sum_assignment((-traj_score))
+ match_i, match_j = linear_sum_assignment(-traj_score)

15-16: Set up logger for Tracker class.

The initialization of the logger instance named logger sets up logging for the Tracker class, which is a best practice for maintainability and debuggability.

dreem/io/instance.py (2)

243-245: Enhanced error logging with logger.exception.

The use of logger.exception improves error handling by logging the exception details, which is a best practice for maintainability and debuggability.


507-509: Enhanced error logging with logger.exception.

The use of logger.exception improves error handling by logging the exception details, which is a best practice for maintainability and debuggability.

Comment on lines +49 to +51
target_inst_id = torch.cat(
[frame.get_gt_track_ids().to(asso_preds[-1].device) for frame in frames]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reconsider removing error handling.

The removal of the try-except block for handling RuntimeError during the concatenation of track IDs can lead to unhandled exceptions and potential crashes. Ensure that the inputs are always valid or re-add the error handling to manage possible exceptions gracefully.

-        target_inst_id = torch.cat(
-            [frame.get_gt_track_ids().to(asso_preds[-1].device) for frame in frames]
-        )
+        try:
+            target_inst_id = torch.cat(
+                [frame.get_gt_track_ids().to(asso_preds[-1].device) for frame in frames]
+            )
+        except RuntimeError as e:
+            print(f"RuntimeError: {e}")
+            raise
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
target_inst_id = torch.cat(
[frame.get_gt_track_ids().to(asso_preds[-1].device) for frame in frames]
)
try:
target_inst_id = torch.cat(
[frame.get_gt_track_ids().to(asso_preds[-1].device) for frame in frames]
)
except RuntimeError as e:
print(f"RuntimeError: {e}")
raise

level: [INFO]
handlers: [empty]


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trailing spaces.

Trailing spaces should be removed to adhere to YAML formatting standards.

-  
+
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Tools
yamllint

[error] 36-36: trailing spaces

(trailing-spaces)

propagate: yes
parent: [loggers.dreem]
root:
level: [INFO]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the root logger's level configuration.

The root logger's level should be set as a string, not a list.

-  level: [INFO]
+  level: INFO
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
level: [INFO]
level: INFO

except Exception as e:
print(gt_ids)
raise (e)
data["gt_ids"] = gt_ids
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reconsider removing error handling.

The removal of the try-except block for handling errors during the assignment of gt_ids to the data dictionary can lead to unhandled exceptions and potential crashes. Ensure that the inputs are always valid or re-add the error handling to manage possible exceptions gracefully.

-    data["gt_ids"] = gt_ids
+    try:
+        data["gt_ids"] = gt_ids
+    except Exception as e:
+        logger.error(f"Error assigning gt_ids: {e}")
+        raise
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
data["gt_ids"] = gt_ids
try:
data["gt_ids"] = gt_ids
except Exception as e:
logger.error(f"Error assigning gt_ids: {e}")
raise

Comment on lines +44 to +45
ref_inds = torch.concat([instance.frame.frame_id for instance in ref_instances])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reintroduce error handling for robustness.

The removal of the try-except block reduces the robustness against runtime errors. Consider reintroducing error handling to prevent potential crashes.

-  ref_inds = torch.concat([instance.frame.frame_id for instance in ref_instances])
+  try:
+      ref_inds = torch.concat([instance.frame.frame_id for instance in ref_instances])
+  except RuntimeError as e:
+      print(f"Error concatenating frame IDs: {e}")
+      raise
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ref_inds = torch.concat([instance.frame.frame_id for instance in ref_instances])
try:
ref_inds = torch.concat([instance.frame.frame_id for instance in ref_instances])
except RuntimeError as e:
print(f"Error concatenating frame IDs: {e}")
raise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant